<!DOCTYPE html>
<html>

  <head>
    <meta charset="UTF-8">
    <title>游戏列表</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/static/super_cmdb/css/font.css">
    <link rel="stylesheet" href="/static/super_cmdb/css/xadmin.css">

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
      <style>
          .hide{
            display: none;
          }
      </style>
  </head>

  <body class="layui-anim layui-anim-up">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">用户列表</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="/configcenter/gameserver_list/" title="刷新">
        <i class="layui-icon" style="line-height:33px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row" style="width: 151px;position: relative"></div>
      <xblock>
          <li class="layui-nav-item">
            <form method="post" id="myform" onchange="submitForm()">
                {% csrf_token %}
                <select id="" name="gameserver_group_id" style="height: 30px;border: 0;width: 200px">
                    <option value="" id="blink">{{ select_group_name }}</option>
                    {% for gameserver_group in gameserver_group_list %}
                        <option value="{{ gameserver_group.id }}">{{ gameserver_group.group_name }}</option>
                    {% endfor %}
                </select>
            </form>
          </li>
      </xblock>

      <xblock>
          <form action="/configcenter/gameserver_list/" method="post" id="gameserver_filter" onchange="submitForm_gameserver_filter()">
              {% csrf_token %}
              <input style="width: 350px;height: 30px;border-radius: 7px;border: 0px;background-color: #e2e2f5;" placeholder="Filter: server_id |服务器名称 |目录名称 |server_ip" name="gameserver_filter" value="{{ gameserver_filter }}" onchange="submitForm();" >
          </form>
      </xblock>

      <xblock>
          <button class="layui-btn" onclick="x_admin_show('配置应用','/configcenter/install_game/',1000,500)"><i class="layui-icon"></i>配置应用</button>
          <span class="x-right" style="line-height:40px">共有应用：{{ game_number }} 个</span>
      </xblock>

    <!-- 遮罩层部分start -->
    <div id="i2" class="hide"></div>
    <!-- 遮罩层部分end -->



      <table class="layui-table" id='table1'>
        <thead>
          <tr>
            <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>server_id</th>
            <th>服务器名称</th>
            <th>目录名称</th>
            <th>server_ip</th>
            <th>配置信息</th>
            <th>备注</th>
            <th>创建时间</th>
            <th>编辑</th>
          </tr>
        </thead>
        <tbody>
            {% for game in game_list %}
              <tr>
                <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{{ game.server_id }}'><i class="layui-icon">&#xe605;</i></div>
                </td>
                <td>{{ game.server_id }}</td>
                <td>{{ game.server_name }}</td>
                <td>{{ game.server_dir }}</td>
                <td>{{ game.server_ip }}</td>
                <td style="color: yellowgreen;"><button style="color: #0e90d2;border: 0;" onclick="x_admin_show('配置信息','/configcenter/gameserver_config_detail-{{ game.server_id }}/',1300,700)">配置信息</button></td>
                <td>{{ game.remarks }}</td>
                <td>{{ game.create_time|date:"Y-m-d H:i:s" }}</td>
                <td class="td-manage">
                    <a title="编辑"  onclick="x_admin_show('编辑','/configcenter/gameserver_edit-{{ game.id }}',700,450)" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                  </a>
                </td>
              </tr>
            {% endfor %}
        </tbody>
      </table>

        <div class="page">
            {% for page_str in page_list %}
                {{ page_str|safe }}
            {% endfor %}
        </div>

    </div>
    <script type="text/javascript" src="/static/super_cmdb/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/super_cmdb/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/super_cmdb/js/xadmin.js"></script>
    <script src="/static/super_cmdb/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/super_cmdb/js/jquery.cookie.js"></script>
    <script>

        //表格选中着色
        var trs = document.getElementById('table1').getElementsByTagName('tr');
        window.onload = function(){
            for( var i=0; i<trs.length; i++ ){
                trs[i].onmousedown = function(){
                    tronmousedown(this);
                }
            }
        };
        function tronmousedown(obj){
            for( var o=0; o<trs.length; o++ ){
                if( trs[o] == obj ){
                    trs[o].style.backgroundColor = 'rgb(174, 212, 234)';
                }
                else{
                    trs[o].style.backgroundColor = '';
                }
            }
        }


        //添加csrftoken
        $(function () {
            $.ajaxSetup({
                beforeSend:function (xhr,settings) {
                    xhr.setRequestHeader("X-CSRFtoken",$.cookie("csrftoken"));
                }
            })
        });

        //分页
        $(function () {
           var v = $.cookie("per_page_count");
           console.log(v)
           $("#pg").val(v);
        });
        function changePageSize(ths) {
            var current_page = $(ths).val();
            console.log(current_page);
            $.cookie("per_page_count", current_page);
            location.reload();
        }


          layui.use('laydate', function(){
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
              elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
              elem: '#end' //指定元素
            });
          });


        function submitForm(){
            //获取form表单对象,提交选择项目
            var form = document.getElementById("myform");
            form.submit();//form表单提交
        }
        function submitForm1(){
            //获取form表单对象,提交选择项目
            var form = document.getElementById("myform1");
            form.submit();//form表单提交
        }

        function submitForm_gameserver_filter(){
            //获取form表单对象,提交选择项目
            var form = document.getElementById("gameserver_filter");
            form.submit();//form表单提交
        }

    </script>
  </body>

</html>
